import model.Game;
import model.World;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * @author Constantine
 */
public class Coords {

    public static double X_MAX;
    public static double X_MIN;
    public static double Y_MAX;
    public static double Y_MIN;
    private static World world;

    public static double getHeight() {
        return Y_MAX - Y_MIN;
    }

    public static double getWidth() {
        return X_MAX - X_MIN;
    }

    public static double getX(double Xcoord) {
        double result = (Xcoord - (getWidth() / 2 + X_MIN)) / (getWidth() / 2);
        if (world.getMyPlayer().getNetBack() < getWidth() / 2) {
            result = 0 - result;
        }
        return result;
    }

    public static double getXcoord(double x) {
        if (world.getMyPlayer().getNetBack() < getWidth() / 2) {
            x = 0 - x;
        }
        return getWidth() / 2 + X_MIN + x * getWidth() / 2;
    }

    public static double getY(double Ycoord) {
        return 0 - (Ycoord - (getHeight() / 2 + Y_MIN)) / (getHeight() / 2);
    }

    public static double getYcoord(double y) {
        y = 0 - y;
        return getHeight() / 2 + Y_MIN + y * getHeight() / 2;
    }

    public static void init(World world, Game game) {
        Coords.world = world;
        X_MIN = game.getRinkLeft();
        X_MAX = game.getRinkRight();
        Y_MIN = game.getRinkTop();
        Y_MAX = game.getRinkBottom();
    }
}
